home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8814 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1004 b 

  1. Path: jetty.telerate.com!jjoshua
  2. From: jjoshua@barcelona.tts.telerate.com (Jonathan Joshua)
  3. Newsgroups: comp.lang.c++
  4. Subject: sizeof inside of enum question
  5. Date: 26 Feb 1996 20:42:03 GMT
  6. Organization: Dow Jones Telerate
  7. Message-ID: <4gt5ur$qi1@jetty.telerate.com>
  8. NNTP-Posting-Host: barcelona.tts.telerate.com
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. I'm having a problem using the sizeof operator inside of an enum. For example:
  12.  
  13. char t [13];
  14. ...
  15. enum { s = sizeof (t) };      <-- Compiler Error
  16.  
  17. However, the following works:
  18.  
  19. enum { s = sizeof (char) }; 
  20.  
  21. The reason for trying to do this is that I am using a design tool that creates
  22. code for me.  In the above example, I don't know what the size of "t" will 
  23. always be.
  24.  
  25. What's the difference?  How can I work around this problem?
  26.  
  27. Thanks,
  28. JOn.
  29.  
  30. ==============================================================================
  31. Jonathan Joshua                                       jjoshua@tts.telerate.com
  32. Principal Software Engineer
  33. Dow Jones Telerate
  34.